//
//  TouchView.m
//  UI29_homeBlock
//
//  Created by dllo on 16/1/21.
//  Copyright © 2016年 Yuming. All rights reserved.
//

#import "TouchView.h"

@interface TouchView ()
@property (strong, nonatomic) IBOutlet UIView *view;

@property (nonatomic, copy) void(^block) (TouchView *);

@property (nonatomic, copy) void(^deleBtnHandle)(UIButton *);

@property (nonatomic, copy) void(^editBtnHandle)(UIButton *);



@end

@implementation TouchView

- (instancetype)initWithCoder:(NSCoder *)aDecoder {

    self = [super initWithCoder:aDecoder];
    
    if (self) {
        
        [[NSBundle mainBundle] loadNibNamed:@"TouchView" owner:self options:nil];
        self.view.frame = self.bounds;
        [self addSubview:self.view];
        
    }
    return self;
}


- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    //点击之后,调用blcok
    self.block(self);

}

/** 实现带block参数的方法 */
- (void)viewDidClick:(void (^)(TouchView *))block {

    self.block = block;


}


/** 点击删除button */
- (IBAction)handleAction:(id)sender {
    
    self.deleBtnHandle((UIButton *)sender);
    
    
}
/** 点击编辑button */
- (IBAction)handleEditAction:(id)sender {
    self.editBtnHandle((UIButton *)sender);
}


- (void)buttonHandle:(void (^)(UIButton *))block {
    self.deleBtnHandle = block;

}

- (void)editBtnHandle:(void (^)(UIButton *))block1 deleButnHandle:(void (^)(UIButton *))block2 {

    
    self.deleBtnHandle = block2;
    self.editBtnHandle = block1;
//    block1(self.editBtn);

}



//- (void)editBtnHandle:(void (^)(UIButton *))block1 deleButnHandle:(void (^)(UIButton *))block2





/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
